<template>
  <div>
    <a-breadcrumb>
      <a-breadcrumb-item v-if="name1&&name1!=name2">{{ name1 }}</a-breadcrumb-item>
      <a-breadcrumb-item v-if="name2"><span v-if="!name4&&isAddOrInfo" class="cursor_pointer" @click="goBack()">{{ name2 }}</span><span v-else>{{ name2 }}</span></a-breadcrumb-item>
      <a-breadcrumb-item  v-if="name3"><span v-if="name4" class="cursor_pointer" @click="goBack()">{{ name3 }}</span><span v-else>{{ name3 }}</span></a-breadcrumb-item>
      <a-breadcrumb-item  v-if="name4">{{ name4 }}</a-breadcrumb-item>
    </a-breadcrumb>
  </div>
</template>

<script>
export default {
  name: "Bread",
  props: {
    names: Array,
    target: Object
  },
  data() {
    console.log(33,this.names)
    let name1 = null, name2 = null, name3 = null,name4=null;
    if (this.names.length == 4) {
      name1 = this.names[0];
      name2 = this.names[1];
      name3 = this.names[2];
      name4 = this.names[3];
    }


    if (this.names.length == 3) {
      name1 = this.names[0];
      name2 = this.names[1];
      name3 = this.names[2];
    }

    if (this.names.length == 2) {
      name1 = this.names[0];
      name2 = this.names[1];
    }

    if (this.names.length == 1) {
      name1 = this.names[0];
    }
    return {
      name1: name1,
      name2: name2,
      name3: name3,
      name4: name4,
      isAddOrInfo:false,
    }
  },
  mounted() {
    // if (!this.names.length) {
    //   this.name1 = this.$route.meta.para2;
    //   this.name2 = this.$route.meta.para;
    //   this.name3 = this.$route.meta.title;
    // }
    console.log(33333,this.$route.fullPath)
    let url = this.$route.fullPath;
    if(url.indexOf('/add')!=-1||url.indexOf('Info?')!=-1){
      this.isAddOrInfo = true;
    }else{
      this.isAddOrInfo = false;
    }
    this.$util.setCurrentBreadTitle(this.name3);
  },
  methods:{
    goBack(){
      this.$router.back()
    }
  }
}
</script>

<style scoped>

</style>
